fix: address audit bug regressions#29
Conversation
📝 WalkthroughWalkthroughThis PR tightens ChangesStrReplaceFile validation tightening
Background task runtime update refactoring
Memory retrieval and inbox consolidation
Compaction context rebuild and wire event guarantees
UI markup safety across shell commands
UI edge cases and optimizations
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/pythinker_code/ui/shell/__init__.py (1)
1264-1264:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winEscape
ChatProviderErrormessages in "Server:" lines.Lines 1264, 1270, 1275, and 1280 render exception objects without escaping, allowing markup injection if error messages contain bracket characters (e.g., from URLs, JSON responses, or file paths).
🔒 Proposed fix
- f"[dim]Server: {e}[/dim]" + f"[dim]Server: {escape(str(e))}[/dim]"Apply this pattern to all four occurrences (lines 1264, 1270, 1275, 1280).
Also applies to: 1270-1270, 1275-1275, 1280-1280
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/pythinker_code/ui/shell/__init__.py` at line 1264, The "Server:" lines interpolate ChatProviderError exception messages directly (pattern: f"[dim]Server: {e}[/dim]") which permits markup injection; update each occurrence to escape the exception text before rendering by importing rich.markup.escape (or equivalent) and replacing {e} with escape(str(e)) so the f-strings become f"[dim]Server: {escape(str(e))}[/dim]" in the code paths where ChatProviderError is handled; apply this change to all four occurrences that currently use the unescaped pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/pythinker_code/ui/shell/__init__.py`:
- Line 1264: The "Server:" lines interpolate ChatProviderError exception
messages directly (pattern: f"[dim]Server: {e}[/dim]") which permits markup
injection; update each occurrence to escape the exception text before rendering
by importing rich.markup.escape (or equivalent) and replacing {e} with
escape(str(e)) so the f-strings become f"[dim]Server: {escape(str(e))}[/dim]" in
the code paths where ChatProviderError is handled; apply this change to all four
occurrences that currently use the unescaped pattern.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 90406527-a4c8-4387-97ed-f1b072170a43
📒 Files selected for processing (25)
CHANGELOG.mdsrc/pythinker_code/background/manager.pysrc/pythinker_code/background/store.pysrc/pythinker_code/background/worker.pysrc/pythinker_code/memory/consolidation.pysrc/pythinker_code/memory/retriever.pysrc/pythinker_code/soul/pythinkersoul.pysrc/pythinker_code/soul/toolset.pysrc/pythinker_code/tools/file/replace.mdsrc/pythinker_code/tools/file/replace.pysrc/pythinker_code/ui/shell/__init__.pysrc/pythinker_code/ui/shell/export_import.pysrc/pythinker_code/ui/shell/session_picker.pysrc/pythinker_code/ui/shell/setup.pysrc/pythinker_code/ui/shell/task_browser.pysrc/pythinker_code/ui/shell/usage.pytasks/agent-behavior-findings.mdtasks/port-bk-box-agent-features.mdtasks/tui-enhancement-plan.mdtasks/tui-text-color-standardization.mdtests/core/test_compaction_restore.pytests/core/test_memory_phase_bcd.pytests/tools/test_str_replace_file.pytests/tools/test_tool_descriptions.pytests/ui_and_conv/test_shell_export_import_commands.py
💤 Files with no reviewable changes (4)
- tasks/tui-enhancement-plan.md
- tasks/tui-text-color-standardization.md
- tasks/agent-behavior-findings.md
- tasks/port-bk-box-agent-features.md
Summary
Verification
git diff --checkuv run pytest tests/tools/test_str_replace_file.py tests/core/test_compaction_restore.py tests/core/test_memory_phase_bcd.py tests/ui_and_conv/test_shell_export_import_commands.py tests/tools/test_tool_descriptions.pySummary by CodeRabbit
Release Notes
New Features
Bug Fixes